package com.szsh.aiot.hsm.dto.enu;

/**
 * 流量识别接口防欺诈类型
 *
 * @author zhangtt
 *
 */
public enum FlowDiscernMaliciousType {

    ALL(0, "All", "网络防护防火墙", "all", "", ""),
    PISHING_SITE(1, "社工欺诈", "钓鱼劫持防火墙", "pishing", "01", "您的设备正在访问的网址疑似为钓鱼、仿冒网站，网址是：%s"),
    VIRUS_FILE(2, "恶意文件", "病毒攻击防火墙", "virusFile", "02", "您的设备正在访问的网址疑似包含病毒、恶意文件等内容，网址是：%s"),
    CHEAT_SITE(3, "信息诈骗", "诈骗网站防火墙", "cheatSite", "03", "您的设备正在访问的网址疑似包含信息诈骗等欺诈内容，网址是：%s"),
    RISK_SITE(3, "风险网站", "诈骗网站防火墙", "cheatSite", "03", "您的设备正在访问的网址疑似包含信息诈骗等欺诈内容，网址是：%s"),
    FAKE_AD(4, "虚假销售", "虚假广告防火墙","fakeAd", "04", "您的设备正在访问的网址疑似包含虚假销售等欺诈内容，网址是：%s"),
    GAMBLE_SITE(5, "博彩网站", "非法内容防火墙", "gambleSite", "05", "您的设备正在访问的网址疑似包含博彩等非法内容，网址是：%s"),
    BLUE_SITE(5, "色情网站", "非法内容防火墙", "gambleSite", "05", "您的设备正在访问的网址疑似包含色情等非法内容，网址是：%s"),
    ILLEGAL_SITE(5, "非法内容", "非法内容防火墙", "gambleSite", "05","您的设备正在访问的网址疑似包含博彩、色情、侵权等非法内容，网址是：%s"),
    BREACH(6, "失陷", "信息泄露防火墙", "breach", "06", "该设备疑似存在失陷行为，失陷类型%s为%s");

    private final int val;
    // 后台获取类型，对应MaliciousType字段
    private final String desc;
    // 用户展示类别
    private final String showDesc;
    // 不同类型标识
    private final String page;
    // 消息推送的contentID
    private final String contentID;
    // 详情展示
    private final String detail;

    FlowDiscernMaliciousType(int val, String desc, String showDesc, String page, String contentID, String detail) {
        this.val = val;
        this.desc = desc;
        this.showDesc = showDesc;
        this.page = page;
        this.contentID = contentID;
        this.detail = detail;
    }

    public int getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    public String getShowDesc() {
        return showDesc;
    }

    public String getPage() {
        return page;
    }
    
    public String getContentID() {
        return contentID;
    }

    public String getDetail() {
        return detail;
    }

    /**
     * 根据描述类型获取防欺诈类型
     * 
     * @param desc
     * @return
     */
    public static int getType(String desc) {
        for (FlowDiscernMaliciousType type : FlowDiscernMaliciousType.values()) {
            if (type.getDesc().contains(desc)) {
                return type.getVal();
            }
        }
        return FlowDiscernMaliciousType.PISHING_SITE.getVal();
    }

    /**
     * 根据描述类型获取防欺诈类型
     * 
     * @param desc
     * @return
     */
    public static FlowDiscernMaliciousType getMaliciosType(String eventType) {
        for (FlowDiscernMaliciousType flowType : FlowDiscernMaliciousType.values()) {
            if (flowType.getPage().equals(eventType)) {
                return flowType;
            }
        }
        return FlowDiscernMaliciousType.PISHING_SITE;
    }

    /**
     * 根据类型获取防欺诈类型
     * 
     * @param desc
     * @return
     */
    public static FlowDiscernMaliciousType getMaliciosByType(int type) {
        for (FlowDiscernMaliciousType flowType : FlowDiscernMaliciousType.values()) {
            if (flowType.getVal() == type) {
                return flowType;
            }
        }
        return FlowDiscernMaliciousType.PISHING_SITE;
    }
}
